﻿using KayakMes.Common.Dtos.ProductControlDTO.Input;
using KayakMes.Common.Result;
using KayakMes.ProductControl.Application.Services;
using KayakMes.ProductControl.Domain.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace KayakMes.ProductControl.API.Controllers
{
    /// <summary>
    /// 产品管理—产品
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        private readonly IProductService productService;

        public ProductController(IProductService productService)
        {
            this.productService = productService;
        }
        #region 产品管理—产品操作
        /// <summary>
        /// 添加产品信息
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public ApiResult<int> AddProduct(ProductModel product)
        {
            return productService.AddProduct(product);
        }
        /// <summary>
        /// 获取所有产品信息以及分页查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public ApiPaging<ProductModel> GetAllProduct(ProductDto dto)
        {
            return productService.GetAllProduct(dto);
        }
        /// <summary>
        ///通过Id获取产品信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public ApiResult<ProductModel> GetProduct(long Id)
        {
           return productService.GetProduct(Id);
        }
        /// <summary>
        ///更新产品信息
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public ApiResult<int> UpdateProduct(ProductModel product)
        {
            return productService.UpdateProduct(product);
        }
        /// <summary>
        /// 逻辑删除产品信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public ApiResult<int> LoginDel(long Id)
        {
            return productService.LoginDel(Id);
        }
        #endregion
    }
}
